package com.time.workbench.efficient.service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.time.workbench.efficient.entity.bo.Application;
import com.time.workbench.efficient.entity.bo.EnvironmentServer;
import com.time.workbench.efficient.entity.bo.Server;
import com.time.workbench.efficient.entity.dto.ApplicationPageReq;
import com.time.workbench.efficient.entity.dto.ServerPageReq;
import com.time.workbench.efficient.mapper.ApplicationMapper;
import com.time.workbench.efficient.mapper.ServerMapper;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;

import java.util.List;

/**
 * 服务器管理service
 */
@Service
@RequiredArgsConstructor
public class ServerService extends ServiceImpl<ServerMapper, Server> implements IService<Server> {

    public Page<Server> page(ServerPageReq serverPageReq) {
        IPage<Server> page = new Page<>(serverPageReq.getCurrent(), serverPageReq.getPageSize());
        return baseMapper.page(page, serverPageReq);
    }

    public List<Server> getByEnvironment(Integer environmentId) {
        return baseMapper.selectByEnvironment(environmentId);
    }
}
